package server.modules.generator.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import server.common.utils.PageUtils;
import server.common.utils.Query;

import server.modules.generator.dao.MeetingDao;
import server.modules.generator.entity.MeetingEntity;
import server.modules.generator.entity.PointEntity;
import server.modules.generator.entity.ProjectEntity;
import server.modules.generator.service.MeetingService;
import server.modules.generator.service.ProjectService;


@Service("meetingService")
public class MeetingServiceImpl extends ServiceImpl<MeetingDao, MeetingEntity> implements MeetingService {
    @Autowired
    ProjectService projectService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<MeetingEntity> page = this.page(
                new Query<MeetingEntity>().getPage(params),
                new QueryWrapper<MeetingEntity>()
        );


        for (MeetingEntity sing : page.getRecords()) {
            ProjectEntity projectEntity = projectService.getById(sing.getProjectId());
            if (null != projectEntity)
                sing.setProjectName(projectEntity.getName());
            else
                sing.setProjectName("未配置");
        }

        return new PageUtils(page);
    }

}